<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"   
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui">
    <body>
        <ui:composition>
            <h:form id="siteTreeForm">

                <p:contextMenu for="siteTree">
                    <p:menuitem value="Deploy site" icon="ui-icon-circle-triangle-e" actionListener="#{editorBean.deploySiteAction()}"
                                update=":mainForm:msgs" rendered="#{initParam['USING_FTP'] == 'true'}"/>
                    <p:menuitem value="Tạo mới" icon="ui-icon-document" oncomplete="createNodeDialog.show()"/>
                    <p:menuitem value="Xem" icon="ui-icon-document" actionListener="#{editorBean.viewNodeAction()}" update=":mainForm"/>
                    <p:menuitem value="Đổi tên" icon="ui-icon-pencil" oncomplete="renameNodeDialog.show()"/>  
                    <p:menuitem value="Xoá" icon="ui-icon-trash" oncomplete="deleteNodeConfirm.show()"/>
                    <p:menuitem value="Upload File" icon="ui-icon-document" oncomplete="uploadFileDialog.show()"/>
                </p:contextMenu>

                <p:tree id="siteTree" value="#{editorBean.root}" var="node" selectionMode="single" dynamic="true"
                        selection="#{editorBean.selectedNode}">
                    <p:treeNode expandedIcon="ui-icon-folder-open"  
                                collapsedIcon="ui-icon-folder-collapsed">  
                        <h:outputText value="#{node.name}"/>  
                    </p:treeNode>  

                    <p:treeNode type="DOCUMENT" icon="ui-icon-document">  
                        <h:outputText value="#{node.name}" />  
                    </p:treeNode>  

                    <p:treeNode type="IMAGE" icon="ui-icon-image">  
                        <h:outputText value="#{node.name}" />  
                    </p:treeNode>  

                    <p:treeNode type="VIDEO" icon="ui-icon-video">  
                        <h:outputText value="#{node.name}" />  
                    </p:treeNode>  
                </p:tree>
                
               <p:confirmDialog message="Bạn có muốn xóa node này?" appendToBody="true"
                                 header="Thông báo" severity="alert" widgetVar="deleteNodeConfirm">  
                    <p:commandButton value="Có" oncomplete="deleteNodeConfirm.hide()" update="siteTreeForm"
                                     actionListener="#{editorBean.deleteNodeAction()}" />  
                    <p:commandButton value="Không" onclick="deleteNodeConfirm.hide()" type="button" />                     
                </p:confirmDialog>
            </h:form>
        </ui:composition>
    </body>
</html>